class TeseCase:
    def __init__(self,name):
        self.testcase_title = name
        self.test_steps = []
        self.test_result = ''

    def add_step(self,step_name):
        self.test_steps.append(step_name)

    def result(self,expect_result):
        self.test_result =expect_result

    def __str__(self):
        title = self.testcase_title
        steps = '\n'.join(self.test_steps)
        result = self.test_result

        return f'测试主题：{title}\n测试步骤：\n{steps}\n测试结果：{result}\n{"*"*30}'

class Testsuit:
    """
    实例方法
    def __init__(self):
        self.case = []

    def add_testcase(self,demo):
        self.case.append(demo)

    def run_case(self):
        print('开始执行')
        for i in self.case:
            print(i)
            print('结束运行')
    """
    #静态方法
    testcases = []
    @staticmethod
    def run_testcase():
        print('执行开始了')
        for i in Testsuit.testcases:
            print(i)
        print('执行结束了')

if __name__ == '__main__':
    testcase1 = TeseCase('模拟用户登录')
    testcase1.add_step('导航至登陆页面')
    testcase1.add_step('输入用户名admin，密码123456')
    testcase1.result('用户登陆成功')
    # print(testcase1.testcase_title)
    # for i in range(len(testcase1.test_steps)):
    #     print(f'第{i+1}步:',testcase1.test_steps[i])
    # print('期望结果：',testcase1.test_result)

    testcase2 = TeseCase('模拟用户注册')
    testcase2.add_step('导航至注册页面')
    testcase2.add_step('输入用户名admin，密码123456，重复密码')
    testcase2.result('用户注册成功')

    # print(testcase1)
    # print(testcase2)
    #实例方法 调用操作：用实例调用
    # smoketest = Testsuit()
    # smoketest.add_testcase(testcase1)
    # smoketest.add_testcase(testcase2)
    # smoketest.run_case()

    #静态方法 调用操作：用类名调用
    Testsuit.testcases.append(testcase1)
    Testsuit.testcases.append(testcase2)
    Testsuit.run_testcase()